{% extends 'layout.html' %}

{% block content %}
    <div class="container">
        <h1>发布任务单: {{ project_object.title }}-{{ project_object.get_env_display }}</h1>
        <div>
            <a style="margin: 10px" class="btn btn-primary" href="{% url 'task_add' project_id=project_object.id %}">添加</a>
        </div>
        <table class="table table-bordered">
            <thead>
            <tr>
                <th>ID</th>
                <th>标识</th>
                <th>状态</th>
                <th>去发布</th>
            </tr>
            </thead>
            <tbody>
            {% for row in task_list %}
                <tr>
                    <th>{{ row.id }}</th>
                    <th>{{ row.uid }}</th>
                    <th>{{ row.get_status_display }}</th>
                    <th>
                        <a href="{% url 'deploy' task_id=row.id %}">去发布</a>
                    </th>
                </tr>
            {% endfor %}

            </tbody>
        </table>
    </div>
{% endblock %}
{% block js %}
    <script>
        function removeRow(ths, rid) {
            var result = confirm('是否确定要删除？');

            if (result) {
                $.ajax({
                    url: '/project/delete/' + rid + '/',
                    type: 'get',
                    dataType: "JSON",
                    success: function (res) {
                        if (res.status) {  // server.py传过来的JSONResponse
                            $(ths).parent().parent().remove();  // 把父亲的父亲移除掉,前端展示效果
                        }
                    }
                });
            }
        }
    </script>
{% endblock %}

